// pages/myDetails/myDetails.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    // 显示不同内容
    isShow1: 'none',
    isShow2: 'none',
    isShow3: 'none',
    isShow4: 'none',
    // 钱包
    itemsMoney: [{
      url: '',
      image: 'iconfont icon-chongzhi1',
      text: '充值',
      color: 'color:#63B8FF'
    }, {
      url: '',
      image: 'iconfont icon-tixian',
      text: '提现',
      color: 'color:red'
    }, {
      url: '',
      image: 'iconfont icon-yinhangqia',
      text: '银行卡',
      color: 'color:#63B8FF'
    }, {
      url: '',
      image: 'iconfont icon-jiaoyijilu',
      text: '交易记录',
      color: 'color:red'
    }],
    second: 60,
    phone: '',
    ismsg: 'block'

  },
  // 发送验证码
  setCode: function (e) {
    var phone_reg = /^1[35789]\d{9}$/;
    if (!phone_reg.test(this.data.phone && this.data.phone.length <= 11 && this.data.phone.length == '')) {
      wx.showToast({
        title: '手机号格式错误',
        icon: "none"
      })
      return;
    };
    //此处省略发送短信验证码功能
    this.setData({
      ismsg: 'none'
    })
    this.timer()
  },
  showSendMsg: function () {
    if (!this.data.alreadySend) {
      this.setData({
        send: true
      })
    }
  },
  hideSendMsg: function () {
    this.setData({
      send: false,
      disabled: true,
      buttonType: 'default'
    })
  },
  timer: function () {
    let promise = new Promise((resolve, reject) => {
      let setTimer = setInterval(
        () => {
          this.setData({
            second: this.data.second - 1
          })
          if (this.data.second <= 0) {
            this.setData({
              ismsg: 'block'
            })
            resolve(setTimer)
          }
        }, 1000)
    })
    promise.then((setTimer) => {
      clearInterval(setTimer)
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    if (options.isShow == 1) {
      this.setData({
        isShow1: 'block'
      })
    } else if (options.isShow == 2) {
      this.setData({
        isShow2: 'block'
      })
    } else if (options.isShow == 3) {
      this.setData({
        isShow3: 'block'
      })
    } else if (options.isShow == 4) {
      this.setData({
        isShow4: 'block'
      })
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})